#include <fstream>
#include <string>
#include <stdio.h>
#include <iostream>
#include <complex>
#include <cmath>

#include "TFile.h"
#include "TTree.h"
#include "TBranch.h"
#include "TH1D.h"
#include "TH2D.h"
#include "TGraph.h"
#include "TGraph2D.h"
#include "TF1.h"
#include "TF2.h"
#include "TMath.h"
#include "TStyle.h"
#include "TCanvas.h"

#ifndef ToDetection
#define ToDetection_h 1

using namespace std;

class ToDetection
{
    public:
        ToDetection(string Path);
        ~ToDetection();

    public:
        void SetHG(TGraph * g);
        void SetHG(TH1D *h1, string title);      // set the histogram/graph axis, line ... 
        void SetHG(TH1D *h1, string Xtitle, string Ytitle);      // set the histogram/graph axis, line ... 
        void SetHG(TH2D *h2, string Xtitle, string Ytitle);      // set the histogram/graph axis, line ... 
        void Initialization();
        double DichotomyRecursion(double Omega, double re, double r, double rm);
        double DichotomyRecursion(double x, double y, double z, double theta, double phi);
        double * DichotomyRecursion(double xe, double ye, double ze, double xq, double yq, double zq, double thetam);
        vector<double> AngleCalculation(vector<pair<double, double>> HitsPosition);
        double * CalculateDetection(vector<double> EmitPars);

        vector<pair<double, double>> CalQuartic(double a, double b, double c, double d);
        unsigned int CalQubic(double *x,double a,double b,double c);

    public:
        TH1D * h1_RICHRadius;
        TH2D * h2_RICHHitPos;
        TH1D * h1_RICHQSum;  
        TH1D * h1_RICHHits;  
        TH1D * h1_Angle;     
        TH1D * h1_ReflectionAngle;
        TH1D * h1_Theta;
        TH1D * h1_Distance;
};
#endif
